<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>hello</div>
    <div>
        <input type="text" value="" id="text"/>
        <button onclick="send()">发送</button>
    </div>
    <div>
        <textarea  id="textarea"></textarea>
    </div>
</body>
<script>
       let client =   new WebSocket("ws://localhost:31001/websocket/test")
       client.onopen = function (e) {
            console.log("Websocket is open now")
           client.send("您好啊")
       }
       client.onmessage = function (e) {
            console.log(e)
           document.getElementById("textarea").innerText=e.data;
       }
       function send() {
            let msg =  document.getElementById("text").value;
           client.send("msg")
       }



</script>
</html>